<template>
  <div class="markdown-container">
    <div class="markdown-wrapper">
      <div class="markdown-body">
        <vue-markdown :source="md"></vue-markdown>
      </div>
      <div class="markdown-decoration"></div>
    </div>
  </div>
</template>

<script>
import VueMarkdown from "vue-markdown";
export default {
  name: "MyMarkdown",
  components: {
    VueMarkdown
  },
  data() {
    return {
      md: ""
    };
  },
  created() {
    // 从后端请求README.md
    this.$axios
      .get("/api/public/docs/README.md", {})
      .then(res => {
        this.md = res.data;
      })
      .catch(err => {
        return Promise.reject(err);
      });
  }
};
</script>

<style scoped>
/* 容器样式 */
.markdown-container {
  padding: 40px 0;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

.markdown-wrapper {
  position: relative;
  max-width: 900px;
  margin: 0 auto;
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
  border-radius: 12px;
  overflow: hidden;
}

/* 装饰元素 */
.markdown-decoration {
  position: absolute;
  top: 0;
  left: 0;
  width: 6px;
  height: 100%;
  background: linear-gradient(to bottom, #ff6b6b, #3a86ff);
}

/* Markdown内容区域 */
.markdown-body {
  background: white;
  padding: 50px;
  border-radius: 12px;
  position: relative;
  z-index: 1;
  margin-left: 15px; /* 为装饰条留出空间 */
}

/* 响应式设计 */
@media (max-width: 768px) {
  .markdown-body {
    padding: 30px;
  }
  
  .markdown-wrapper {
    max-width: 95%;
  }
}

@media (max-width: 480px) {
  .markdown-body {
    padding: 20px 15px;
    margin-left: 10px;
  }
  
  .markdown-decoration {
    width: 4px;
  }
}
</style>

<style>
/* 导入基础样式后增强部分元素 */
@import "../assets/css/github-markdown.css";

/* 增强标题样式 */
.markdown-body h1, 
.markdown-body h2, 
.markdown-body h3 {
  position: relative;
  padding-bottom: 10px;
  margin-top: 1.5em;
}

.markdown-body h1 {
  font-size: 2.2em;
  color: #2c3e50;
  border-bottom: 2px solid #f0f0f0;
}

.markdown-body h2 {
  font-size: 1.8em;
  color: #34495e;
}

.markdown-body h3 {
  font-size: 1.4em;
  color: #7f8c8d;
}

/* 增强代码块样式 */
.markdown-body pre {
  border-radius: 8px;
  background: #282c34 !important;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.markdown-body code {
  font-family: 'Fira Code', 'Courier New', monospace;
}

/* 增强列表样式 */
.markdown-body ul, 
.markdown-body ol {
  padding-left: 1.8em;
}

.markdown-body li {
  margin-bottom: 0.5em;
}

.markdown-body ul li::before {
  content: "•";
  color: #ff6b6b;
  font-weight: bold;
  display: inline-block;
  width: 1em;
  margin-left: -1em;
}

/* 增强链接样式 */
.markdown-body a {
  color: #3a86ff;
  text-decoration: none;
  transition: all 0.2s;
  border-bottom: 1px dashed rgba(58, 134, 255, 0.3);
}

.markdown-body a:hover {
  color: #ff6b6b;
  border-bottom-color: #ff6b6b;
}

/* 增强表格样式 */
.markdown-body table {
  border-collapse: collapse;
  width: 100%;
  margin: 1.5em 0;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.03);
}

.markdown-body th, 
.markdown-body td {
  padding: 12px 15px;
  border: 1px solid #e0e0e0;
}

.markdown-body th {
  background: #f8f9fa;
  font-weight: 600;
}

.markdown-body tr:nth-child(even) {
  background: #f8f9fa;
}

/* 增强引用样式 */
.markdown-body blockquote {
  border-left: 4px solid #3a86ff;
  background: #f8f9fa;
  padding: 1em;
  border-radius: 0 8px 8px 0;
  margin: 1.5em 0;
}

.markdown-body blockquote p {
  margin: 0;
  color: #555;
}
</style>